#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from common.readelement import Element
from page_object.webpage import WebPage
from tools.logger import log

viewresume = Element('jzsz/enterprise/viewresume')

class ViewResumePage(WebPage):

    def open_viewresumelist(self):
        """打开全职简历页面"""
        self.is_click(viewresume['用户信息'])
        self.is_click(viewresume['查看简历'])

    def get_reach_intention_num(self):
        """查看达成意向数量"""
        self.is_click(viewresume['达成意向tab'])
        res = self.is_exists2(viewresume['总量'])
        if res:
            text = self.find_element(viewresume['总量']).text
            resume_num = text[2:-2]
            return resume_num
        else:
            return '0'

    def view_detailinfo(self):
        """查看简历详情"""
        self.is_click(viewresume['未查阅tab'])
        self.is_click(viewresume['查看'])

    def invite_interview(self):
        """邀请面试"""
        self.is_click(viewresume['邀请面试'])

    def input_interviewinfo(self,name,mobile):
        self.is_click(viewresume['面试方式'])
        self.is_click(viewresume['选择方式'])
        self.is_click(viewresume['面试时间'])
        self.is_click(viewresume['选择时间'])
        self.input_text(viewresume['联系人'],name)
        self.input_text(viewresume['联系电话'], mobile)
        self.is_click(viewresume['确定'])

    def reach_intention(self):
        self.is_click(viewresume['达成意向'])
        self.is_click(viewresume['确认'])

    def opera_result(self,resume_num):
        """验证达成意向操作成功"""
        self.is_click(viewresume['返回'])
        self.is_click(viewresume['达成意向tab'])
        res = self.is_exists2(viewresume['总量'])
        if res:
            text = self.find_element(viewresume['总量']).text
            resume_num2 = text[2:-2]
            if int(resume_num2) == int(resume_num) + 1:
                return True
            else:
                return False
        else:
            return False